package games.tankwars.behaviors;


/**
 * When two of the objects interest the collision causes the object to stop but not change direction.
 * 
 * @author Jonathan Odom
 * @author Aneesh Butani
 */
public class IntersectAndStop extends Intersect
{
    public IntersectAndStop (vooga.geom.Vector velocity,
    		vooga.entities.Entity obstacle)
    {
        super(velocity, obstacle);
    }

    public IntersectAndStop (vooga.geom.Vector velocity,
                               java.util.List<vooga.entities.Entity> obstacles)
    {
        super(velocity, obstacles);
    }
    
    public IntersectAndStop (vooga.geom.Vector velocity,
            java.util.Collection<vooga.entities.Entity> obstacles)
    {
    	super(velocity, obstacles);
	}


    protected void onCollide (vooga.entities.Entity lhs, vooga.entities.Entity rhs)
    {
    	int dx[]={-2,0,2,0};
    	int dy[]={0,2,0,-2};
    	vooga.geom.Vector zeroVector = new vooga.geom.Vector (lhs.getHeading(), 0);
    	System.out.println(Math.abs(lhs.getHeading()/90));
    	lhs.translate(dx[(int)Math.abs(lhs.getHeading()/90)], dy[(int)Math.abs(lhs.getHeading()/90)]);
    	lhs.setVelocity(zeroVector);
    }
}
